<script setup lang="ts">
import addressConfig from '../config/address.js';

const scrollToTop = () => {
  window.scrollTo({
    top: 0,
    behavior: 'smooth'
  });
};
</script>

<template>
  <div class="fixed-sidebar">
    <a :href="`tel:${addressConfig.phone}`" title="电话咨询">
      <i class="fas fa-phone-alt"></i>
    </a>
    <a :href="`mailto:${addressConfig.email}`" title="邮件咨询">
      <i class="fas fa-envelope"></i>
    </a>
    <router-link to="/contact#message-form" title="在线留言">
      <i class="fas fa-comment-dots"></i>
    </router-link>
    <a href="#" @click.prevent="scrollToTop" title="返回顶部">
      <i class="fas fa-arrow-up"></i>
    </a>
  </div>
</template>

<style scoped>
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css');

.fixed-sidebar {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  background: #fff;
  border-radius: 16px 0 0 16px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.15);
  z-index: 9999;
  padding: 18px 0 18px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 64px;
}

.fixed-sidebar a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 10px 0 auto;
  border-radius: 50%;
  background: none;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  color: #444;
  font-size: 28px;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  will-change: transform;
}

.fixed-sidebar a::after {
  content: attr(title);
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.fixed-sidebar a:hover {
  width: auto;
  padding-right: 44px;
  padding-left: 16px;
  margin-right: 0;
  background: #f0f0f0;
  color: #0d6efd;
  border-radius: 22px;
  transform: translateZ(0);
}

.fixed-sidebar a:hover::after {
  opacity: 1;
  visibility: visible;
  right: calc(100% + 10px);
}

.fixed-sidebar i {
  font-size: 28px;
  display: block;
}

@media (max-width: 768px) {
  .fixed-sidebar {
    display: none;
  }
}
</style>